/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package predictor.gui.dataviewer;

import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import weka.core.Instances;

/**
 *
 * @author Administrator
 */
public class TableRowHeader extends JTable {

    private int m_minLength;
    private int m_nLength;

    public TableRowHeader(int h) {
        super(h, 1);
        m_minLength = h;
        m_nLength = h;
        this.setValue();
        this.setEnabled(false);
        this.setVisible(true);
    }

    private void setValue() {
        for (int i = 0; i < m_nLength; i++) {
            setValueAt(i + 1, i, 0);
        }
    }

    public void setInstances(Instances data) {
        if (data == null) {
            m_nLength = m_minLength;
        } else {
            int n = data.numInstances();
            m_nLength = m_minLength > n ? m_minLength : n;
        }
        DefaultTableModel model = new DefaultTableModel(m_nLength, 1);
        this.setModel(model);
        setValue();
    }

    public void setMinWidth(int width) {
        this.getColumnModel().getColumn(0).setMinWidth(width);
    }
}
